<!DOCTYPE html>
<html>

	<head>
		<style>
			body,html {
				background: #F4F4F4;
			}			
			.gouwuche {
				background: #FFFFFF !important;
			}

		</style>
		<link rel="stylesheet" href="<?php echo APP_TEMPLATES_URL;?>/css/checkbix.min.css" />
		<link rel="stylesheet" href="<?php echo APP_TEMPLATES_URL;?>/css/public.css" />
		<script src="<?php echo APP_TEMPLATES_URL;?>/js/checkbix.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			Checkbix.init();
		</script>
	</head>

	<body>
		<!-- 导航 -->
		<div class="mui-bar mui-bar-nav bj">
			<button class="mui-btn mui-btn-link mui-btn-nav mui-pull-left zys  mui-action-back">
				<img style=" max-width: 50%; vertical-align: middle;" src="<?php echo APP_TEMPLATES_URL;?>/images/back.png" />
			</button>
			<button class="mui-btn mui-btn-link mui-btn-nav mui-pull-right" style="margin-right: 15px;">
				<a href="index.php?act=cart&op=goods_cart">完成</a>
			</button> &nbsp;
			<button class="mui-btn mui-btn-link mui-btn-nav mui-pull-right" style="margin-right: 20px;">
				<!--<a href="index.php?act=temp&op=cart">领劵</a>-->
			</button>
			<h1 class="mui-title"><label style="font-size: 22px;vertical-align: middle;">购物车</label></h1>
		</div>
		<!-- 主体内容 -->

		<script type="text/javascript">
			$(document).ready(function() {

				//jquery特效制作复选框全选反选取消(无插件)
				// 全选        
				$("#allselect").click(function() {
					if($(this).attr("checked")) {
						$(".gouwuche input[name=boxlist]").each(function() {
							$(this).attr("checked", true);
						});
					} else {
						$(".gouwuche input[name=boxlist]").each(function() {
							$(this).attr("checked", false);
						});
					}
				});

				// 所有复选(:checkbox)框点击事件
				$(".gouwuche input[name=boxlist]").click(function() {
					if($(this).attr("checked")) {
						//$(this).next().css({ "background-color": "#3366cc", "color": "#ffffff" });
					} else {
						// $(this).next().css({ "background-color": "#ffffff", "color": "#000000" });
					}
				});

				//删除
				$(".buttomcop").click(function() {
					GetCount();
				});

			});

			function countadd(obj, cart_id, goods_storage) {
				var t = $(obj).prev();
				if(parseInt(t.val())<goods_storage){
					t.val(parseInt(t.val()) + 1)
					setCartNum(cart_id,parseInt(t.val()));
				}
			}

			function countcut(obj, cart_id) {
				var t = $(obj).next();
				var count1 = parseInt(t.val());
				if (count1 <= 1) {
					t.val(1);
				} else {
					t.val(count1-1);
					setCartNum(cart_id,parseInt(t.val()));
				}
			}

			function setCartNum(cart_id, quantity){
				$.getJSON('index.php?act=cart&op=update&cart_id=' + cart_id + '&quantity=' + quantity , function(result){
					if(!result.state){
						alert('更改失败!');
					}
				});
			}

			//******************
			/*
			 * 删除
			 */
			function GetCount() {
				var cart_ids = '';
				$(".gouwuche input[name=boxlist]").each(function() {
					if($(this).attr("checked")) {
						cart_ids+='|'+$(this).val();
					}
				});
				if(cart_ids==''){alert("请选择要删除的商品");return;}
				if(!confirm('确定删除此商品吗？'))return;

				$.getJSON('index.php?act=cart&op=del&cart_ids=' + cart_ids.substring(1), function(result){
					if(result.state){
						//删除成功
						if(result.quantity == 0){//判断购物车是否为空
							window.location.href = 'index.php?act=cart&op=goods_cart';
						} else {
							$(".gouwuche input[name=boxlist]").each(function() {
								if($(this).attr("checked")) {
									var $temp ;
									for(var i = 0; i < $(this).length; i++) {

										$temp = $(this).parent().parent().prev();
										$temp.html("");

										$temp = $(this).parent().parent();
										$temp.html("");
									}
								}
							});
						}
					}else{
						alert(result.msg);
					}
				});
			}
		</script>

		<section>
			<!--                	
                	时间：2016-11-07
                	描述：分类
               -->
			<table width="100%">
				<?php foreach ($output['cart_list'] as $cart_info) { ?>
				<tr>
					<td colspan="3">
						<div style="height: 10px; background: #F4F4F4; clear: both;"></div>
					</td>
				</tr>

				<tr class="gouwuche">
					<td width="10" style="padding: 15px 10px 10px 10px;" class="veralignmiddle">
						<input id="<?php echo $cart_info['cart_id']; ?>" type="checkbox" class="checkbix" data-shape="circled" name="boxlist" data-color="orange" data-text="" value="<?php echo $cart_info['cart_id']; ?>">
					</td>
					<td width="100" style="padding: 15px 0 10px 0;"><img style=" width: 100px; border: 1px solid #EEEEEE !important;" src="<?php echo cthumb($cart_info['goods_image'],265);?>" /></td>
					<td style="padding:12px 10px 10px 10px; vertical-align: top;">
						<div style="padding: 4px 0 10px 10px; text-align: center;">
							<img class="countcut" src="<?php echo APP_TEMPLATES_URL;?>/images/GG_11.jpg" onclick="countcut(this,<?php echo $cart_info['cart_id']; ?>);" style="width: 30px;float: left;" />
							<input style="color: #333333; width: 50%;" class="countm" value="<?php echo $cart_info['goods_num']; ?>" readonly="readonly" type="number" />
							<img class="countadd" src="<?php echo APP_TEMPLATES_URL;?>/images/GG_1.jpg" onclick="countadd(this,<?php echo $cart_info['cart_id']; ?>,<?php echo $cart_info['goods_storage']; ?>);" style="width: 30px; float: right;" />
						</div>
						<p class="corbbbbbb ft13 marge20"><?php echo $cart_info['goods_name']; ?></p>
						<div>
							<span class="corc10a1f ft13">￥<label id="price" class="corc10a1f ft13"><?php echo $cart_info['goods_price']; ?></label></span>
							<span style="margin-left: 20px;" class="corefb33e ft13">年收益<?php echo $cart_info['year_rate']; ?>%</span>
						</div>
					</td>
				</tr>
				<?php } ?>
			</table>

			<div style="background: #F4F4F4;clear: both;"></div>
		</section>

		<!--
                	作者：569154771@qq.com
                	时间：2016-11-11
                	描述：去结算
                -->

		<style>
			.buttomcop {
				font-size: 20px;
				line-height: 70px;
				color: #000000;
				background: #f0b33e;
				float: left;
				text-align: center;
				width: 100%;
				margin-top: -1px;
			}
			
			.qujiesuan {
				background: #FFFFFF;
				position: fixed;
				bottom: 0px;
				width: 100%;
				border-top: 1px solid #EEEEEE;
			}
		</style>
		<div class="qujiesuan">
			<table width="100%">
				<tr>
					<td width="77" style="padding: 0px 0px 0px 10px;" class="veralignmiddle">
						<input name="allselectindex" type="hidden" value="false" />
						<input id="allselect" type="checkbox" class="checkbix" data-shape="circled" data-color="orange" data-text=""><label for="allselect" style="vertical-align: top;font-size: 20px;">全选</label>
					</td>
					<td width="0"></td>
					<td style="font-size: 14px; text-align: right;" class="veralignmiddle"></td>
					<td width="100">
						<a class="buttomcop" href="#">删除</a>
					</td>
				</tr>
			</table>
		</div>
	</body>

</html>